package com.mxsat.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;

import reactor.core.publisher.Mono;

@Component
public class GlobalTestFilter implements GlobalFilter{

	@Override
	public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
		System.out.println("这里是全局的过滤！"+this.getClass().getName());
		ServerHttpRequest.Builder builder = exchange.getRequest().mutate();
        builder.header("GlobalFilter","GlobalFilter success");
        return chain.filter(exchange.mutate().request(builder.build()).build());
	}

}
